package com.moter.demo01.io.in_outputstream.objectstream;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Date;

public class ObjectOutputStreamDemo {
    public static void main(String[] args) throws IOException {
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("src\\main\\java\\com\\moter\\demo01\\io\\in_outputstream\\objectstream\\object1.txt"));
        objectOutputStream.writeObject(new Person("moter",21));
        objectOutputStream.flush();
        objectOutputStream.close();
    }
    static class Person implements Serializable {
        private String name;
        private Integer age;

        public Person(String name, Integer age) {
            this.name = name;
            this.age = age;
        }

        @Override
        public String toString() {
            return "Person{" +
                    "name='" + name + '\'' +
                    ", age=" + age +
                    '}';
        }
    }
}
